<?php
class Account_Controller extends TinyMVC_Controller
{
	function index(){
		$header['title'] = '已有帐户';
		$this->view->assign('header', $header);
		//var_dump($this->ac);
		$this->load->model('Account_Model', 'account');
		$data = $this->account->findall();
		$this->view->assign('data', $data);
		
		$this->view->display('account_view');
	}
	
	function login(){
		$errmsg = '';
		if(empty($_POST)){			
			
		}else{
			$this->load->model('Account_Model', 'account');
			$data = $this->account->login($_POST['email'], $_POST['password']);
			if($data == -1){
				$errmsg = '两项都要填写';
			}elseif(!$data){
				$errmsg = '邮箱或密码有错';
			}else{
				//$errmsg = '登录成功，马上返回';
				$_SESSION['uid'] = 'wwww';
				//var_dump($_SESSION);
				//die();
				//$this->view_display('')
			}
		}
		$header['keywords'] = '哈途登录 关键字';
		$header['title'] = '登录吧，蛋炒饭！';
		$this->view->assign('header', $header);
		$this->view->assign('errmsg', $errmsg);
		$this->view->display('account_login_view');
	}
	
	function logout(){		
		if(isset($_SESSION) && !empty($_SESSION)){
			//var_dump($_SESSION);
			unset($_SESSION['uid']);
			session_destroy();
			header('Location: /hello/');
		}else{
			//header('Location: /account/login'); //back to login
			//var_dump($_SESSION);
		}
	}
	
	function register(){
		if(empty($this->uri->path[1])){
			echo 'You must get a code';
		}else{
			var_dump($this->uri->path);
		}
		
	}
}

?>
